﻿using Anke.SHManage.MSSQLDAL.TJDAL;
using Microsoft.Reporting.WebForms;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Anke.SHManage.Web.Reports
{
    public partial class CarManage_AccidentModeWebForm : System.Web.UI.Page
    {
       
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                InitPage();
            }
            
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            BindReportDataSource();

        }
        private void InitPage()
        {
            this.StartDate.Text = DateTime.Now.ToString("yyyy-01-01 00:00:00");
            this.EndDate.Text = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
            BindReportDataSource();
        }
        protected void BindReportDataSource()
        {
            DateTime beginTime = Convert.ToDateTime(this.StartDate.Text);
            DateTime endTime = Convert.ToDateTime(this.EndDate.Text);
          
            string txtCenter = Convert.ToString(this.Center.Text);
            string stationID = Convert.ToString(this.Station.Text);
            string Level = Convert.ToString(this.HiddenFieldL.Value);
            string Responsibility = Convert.ToString(this.HiddenFieldR.Value);


            this.ReportViewer1.LocalReport.DataSources.Clear();
            this.ReportViewer1.LocalReport.ReportPath = Server.MapPath(@"~/Reports/CM_Accident.rdlc");

            TJDAL dal = new TJDAL();

            DataTable dt = dal.Get_TJ_BalanceDetial(Level, Responsibility);
                    this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetCMA", dt));
            
         
            this.ReportViewer1.LocalReport.Refresh();
        }

    }
}